<?php
class Classification extends AppModel {
	var $name = 'Classification';
	var $displayField = 'name';
	var $validate = array(
		'name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				
			),
		),
		'total_company' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				
			),
		),
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $hasMany = array(
		'ClassificationCompany' => array(
			'className' => 'ClassificationCompany',
			'foreignKey' => 'classification_id',
		)
	);

        public function getClassifications($parent = null){
            if($parent){
                $classification = $this->find('all', array('conditions' => array('Classification.parent_id' => $parent), 'recursive' => -1));
            }else{
                $classification = $this->find('all', array('conditions' => array('Classification.parent_id' => 0), 'recursive' => -1));
            }
            return $classification ;
        }
        
        public function getClassify($id){
            if($id){
                return $this->find('first', array('conditions' => array('Classification.id' => $id), 'recursive' => -1));
            }else{
                return false;
            }
        }

}
?>